<link rel="stylesheet" type="text/css" href="/static/css/h5/index.css" />
<link rel="stylesheet" href="/static/css/pc/common.less" />
<link rel="stylesheet/less" type="text/css" href="/static/css/pc/index.less">
<div class="" id="content" val="14" style="width: 420px;">
    <div class="bkms">
        <h3 class="tit">数码家电</h3>
        <div class="more">
            <p class="txt">更多</p>
            <img class="img" src="/static/images/h5/rightArrow.png" alt="">
        </div>
        <div class="clear"></div>
    </div>
    <div class="mzhfImg">
        <img src="/static/images/h5/smjd_ban.png" alt="">
    </div>
    <div class="familyLife">
        <div class="flList">
            <div style="z-index: 999;position: relative;top: 75px;height: 0;">
                <a class="buy-btn" val="1" style="width:90px!important;" name="checkProduct">点击选择1</a>
            </div>
            <img src="/static/images/background.png" style="width: 120px;height: 157px;">
        </div>
        <div class="flList">
            <div style="z-index: 999;position: relative;top: 75px;height: 0;">
                <a class="buy-btn" val="2" style="width:90px!important;" name="checkProduct">点击选择2</a>
            </div>
            <img src="/static/images/background.png" style="width: 120px;height: 157px;">
        </div>
        <div class="flList">
            <div style="z-index: 999;position: relative;top: 75px;height: 0;">
                <a class="buy-btn" val="3" style="width:90px!important;" name="checkProduct">点击选择3</a>
            </div>
            <img src="/static/images/background.png" style="width: 120px;height: 157px;">
        </div>
    </div>
    <div class="xdqd">
        <img src="/static/images/h5/xdqd.jpg" alt="">
    </div>
</div>
<!-- <div class="modal hide fade" id="checkProductInfoByName" style="width: 700px;" tabindex="-1" role="dialog">
    <div class="modal-header">
        <button class="close" type="button" data-dismiss="modal">×</button>
        <h3 id="addRoleModalLabel">选择商品信息</h3>
    </div>
    <div class="modal-body">
        <form id="dataForm" class="definewidth m20" enctype="multipart/form-data">
            <input type="hidden" id="id" />
            <input type="hidden" id="config_id" />
            <table class="table table-bordered table-hover definewidth m10">
                <tr>
                    <td style="width: 25%;" class="tableleft">商品名称</td>
                    <td style="width: 63%;">
                        <input type="text" id="productName" style="width: 300px;" class="required-control" />
                        <span style="color:red;">*</span>
                    </td>
                    <td>
                        <a href="javascript:void(0);" id="queryProductInfo" class="btn btn-primary">查询</a>
                    </td>
                </tr>
            </table>
        </form>
        <table id="taskList_table" class="table table-bordered table-hover definewidth">

        </table>
    </div>
    <div class="modal-footer">
        <a href="javascript:$('.required-control').each(function(){$(this).css('border','1px solid #ccc');$(this).attr('placeholder','');});$('#checkProductInfoByName').modal('hide');$('#dataForm')[0].reset();" class="btn">关闭</a>
        <a href="javascript:void(0);" id="doSaveProduct" class="btn btn-primary">保存</a>
    </div>
</div>
<script type="text/javascript">
    _function.queryUserInfo({
        t: 'indexProductConfig',
        config_id: $('#content').attr('val')
    }, function(data) {
        if (null != data && null != data.products_id) {
            var produsts = JSON.parse(data.products_id);
            if (null != produsts && produsts.length > 0) {
                $.each(produsts, function(index, val) {
                    $(".buy-btn[val=" + val.id + "]").text('点击修改' + val.id).css('background-color', 'red').css('border', '1px solid red');
                });
            }
        }
    })
    var columns = [{
        field: 'id',
        title: '选择',
        width: '50',
        align: 'center',
        formatter: function(value, row, index) {
            return '<input type="checkbox" name="checkProductId" value="' + value + '"/>';
        }
    }, {
        field: 'name',
        title: '商品名称',
        align: 'center'
    }, {
        field: 'shopname',
        title: '所属店铺',
        align: 'center'
    }, {
        field: 'price',
        title: '所属价格',
        align: 'center'
    }, {
        field: 'status',
        title: '状态',
        align: 'center',
        formatter: function(value, row, index) {
            if (value == 0) {
                return '上架'
            } else {
                return '下架';
            }
        }
    }];
    // 渲染table
    initTablePage({
        t: 'product',
        sqlCount: 'queryListPageCount'
    }, {
        column: columns
    });
    //点击选择
    $("a[name='checkProduct']").click(function() {
        $("#id").val($(this).attr('val'));
        $("#checkProductInfoByName").modal("show");
    });
    //查询
    $("#queryProductInfo").click(function() {
        initTablePage({
            t: 'product',
            sqlCount: 'queryListPageCount',
            name: $("#productName").val()
        }, {
            column: columns
        });
    });
    //保存
    $("#doSaveProduct").click(function() {
        if ($('input[name="checkProductId"]:checked').length > 1) {
            alert_msg("只能选择一条");
            return false;
        }
        _function.queryUserInfo({
            t: 'indexProductConfig',
            config_id: $('#content').attr('val')
        }, function(data) {
            if (null != data) {
                if (null != data && null != data.products_id) {
                    var produstArray = JSON.parse(data.products_id);
                    $('input[name="checkProductId"]:checked').each(function(index, val) {
                        var requData = $(this).val();
                        var flg = true;
                        $.each(produstArray, function(index, val) {
                            if (val.id == $('#id').val()) {
                                flg = false;
                                val.product_id = requData;
                                return false;
                            } else {
                                flg = true;
                                return true;
                            }
                        })
                        if (flg) {
                            var produsts = {};
                            produsts.id = $('#id').val();
                            produsts.product_id = $(this).val();
                            produstArray.push(produsts);
                        }
                    });
                    _function.editUserInfo({
                        t: 'indexProductConfig',
                        id: data.id,
                        config_id: $('#content').attr('val'),
                        products_id: JSON.stringify(produstArray)
                    }, function(data) {
                        $(".buy-btn[val=" + $('#id').val() + "]").text('点击修改' + $('#id').val()).css('background-color', 'red').css('border', '1px solid red');
                        $("#checkProductInfoByName").modal("hide");
                    })
                }
            } else {
                var array = [];
                $('input[name="checkProductId"]:checked').each(function(index, val) {
                    var produsts = {};
                    produsts.id = $('#id').val();
                    produsts.product_id = $(this).val();
                    array.push(produsts);
                });
                _function.editUserInfo({
                    t: 'indexProductConfig',
                    config_id: $('#content').attr('val'),
                    products_id: JSON.stringify(array)
                }, function(data) {
                    $(".buy-btn[val=" + $('#id').val() + "]").text('点击修改' + $('#id').val()).css('background-color', 'red').css('border', '1px solid red');
                    $("#checkProductInfoByName").modal("hide");
                })
            }
        });
    });
</script> -->